﻿using GiveMeMenu.Service.ObjectModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GiveMeMenu.Service.Translations
{
    public static class DbToObjectModel
    {
        public static Dish ToDishObjectModel(this GiveMeMenu.DataAccess.Dish from)
        {
            return new Dish()
            {
                Description = from.Description,
                Discount = from.Discount,
                Name = from.Name,
                OId = from.OId,
                Price = from.Price,
                Today = from.Today,
                TypeId = from.TypeId
            };
        }

        public static IList<Dish> ToDishsObjectModel(this IList<GiveMeMenu.DataAccess.Dish> from)
        {
            IList<Dish> result = new List<Dish>();
            foreach (GiveMeMenu.DataAccess.Dish item in from)
            {
                result.Add(item.ToDishObjectModel());
            }
            return result;
        }

        public static LuTypeDish ToLookupTypeDishObjectModel(this GiveMeMenu.DataAccess.luTypeDish from)
        {
            return new LuTypeDish()
            {
                OId = from.OId,
                Name = from.Name
            };
        }

        public static IList<LuTypeDish> ToLookupTypeDishsObjectModel(this IList<GiveMeMenu.DataAccess.luTypeDish> from)
        {
            IList<LuTypeDish> result = new List<LuTypeDish>();
            foreach (GiveMeMenu.DataAccess.luTypeDish item in from)
            {
                result.Add(item.ToLookupTypeDishObjectModel());
            }
            return result;
        }

        public static LuTable ToLookupTableObjectModel(this GiveMeMenu.DataAccess.luTable from)
        {
            return new LuTable()
            {
                OId = from.OId,
                Name = from.Name
            };
        }

        public static IList<LuTable> ToLookupTablesObjectModel(this IList<GiveMeMenu.DataAccess.luTable> from)
        {
            IList<LuTable> result = new List<LuTable>();
            foreach (GiveMeMenu.DataAccess.luTable item in from)
            {
                result.Add(item.ToLookupTableObjectModel());
            }
            return result;
        }

        public static OrderInformation ToOrderInformationObjectModel(this GiveMeMenu.DataAccess.GetOrderInformationByOrderIdResult from)
        {
            return new OrderInformation()
            {
                DishId = from.DishId,
                OrderId = from.OrderInformationId,
                OrderConfirm = from.OrderConfirm,
                OrderDay = from.OrderDate,
                TableId = from.TableId
            };
        }

        public static IList<OrderInformation> ToOrderInformationObjectModel(this IList<GiveMeMenu.DataAccess.GetOrderInformationByOrderIdResult> from)
        {
            IList<OrderInformation> result = new List<OrderInformation>();
            foreach (GiveMeMenu.DataAccess.GetOrderInformationByOrderIdResult item in from)
            {
                result.Add(item.ToOrderInformationObjectModel());
            }
            return result;
        }
    }
}
